Skip to content

feat: expose Q7 robot position - #1041

Open
ramon-angosto wants to merge 4 commits into
Python-roborock:mainfrom
ramon-angosto:q7/4-robot-position
Open

ramon-angosto wants to merge 4 commits into
Python-roborock:mainfrom
ramon-angosto:q7/4-robot-position

Conversation

@ramon-angosto

Copy link
Copy Markdown

Depends on #1040. Only the last commit belongs to this PR.

Summary

Adds MapContentTrait.robot_position for Q7 devices, in common Roborock coordinates (Q7RoborockPoint). It notifies the existing map content listeners when it changes. This is what Home Assistant needs for vacuum.get_current_position.

The position comes from two sources:

  1. Live map frames. The pose in currentPose is used. The firmware reports (1100, 1100) or (0, 0) when the pose is unknown, so poses outside the map bounds or exactly at the origin are ignored and the last known position is kept.
  2. cur_path device pushes. While a task runs, the device sends prop.post pushes with cur_path: [start_index, x, y, phi, kind, ..., timestamp] (world meters). The last sample is used.

Changes

  • Q7DevicePush and decode_device_push() in b01_q7_protocol decode unsolicited *.post messages.
  • Q7PushChannel protocol, implemented by B01Q7Channel.subscribe_device_pushes().
  • Q7PropertiesApi takes a push_channel and subscribes to device pushes in start().
  • parse_robot_pose() helper in roborock/map/b01_map_parser.py.
  • MapContentTrait.refresh_live() requests the live map by type (service.upload_by_maptype {"map_type": 0}). Unlike the saved map (upload_by_mapid), it carries the current pose, and it makes the device stream cur_path positions. Integrations can call it while the robot is cleaning to get an up-to-date map and position.

Testing

  • Unit tests for push decoding, the channel subscription, cur_path parsing (including malformed pushes), placeholder poses and refresh_live().
  • Verified on a Q7 TF+ (roborock.vacuum.sc05, firmware 03.01.80) while cleaning rooms and zones.

Add `clean_zone` and `clean_zones` to the Q7 properties API. Zones are given
as two opposite corners in the common Roborock millimetre coordinate space
through a new `Q7RoborockPoint`, which converts to and from the Q7 world
coordinates (meters, origin next to the dock).

The device expects the zone preference type to be selected first
(`service.set_preference_type`), then the zone corners as a flat list
(`service.set_zone_points`), and finally `service.set_zone_clean` to start.
Several zones are concatenated into a single task.
Add a `RemoteTrait` to the Q7 properties API, mirroring the Q10 remote API.
Manual mode is entered with `prop.set sweep_type=5` and the robot is driven
with `service.set_direction` (1 forward, 2 left, 3 right, 0 exit). Each
command moves the robot for a short burst, so callers repeat it while a
direction is held. Leaving remote mode restores `sweep_type=0`.
Add `set_carpet_turbo` and `set_carpet_avoid` to the Q7 properties API. Both
are written individually with `prop.set` (`carpet_turbo` / `carpet_avoid`)
and reported back nested under `privacy`.

Keep the user-visible `name` of each entry returned by
`service.get_map_list`, which was previously dropped.
Add `MapContentTrait.robot_position` (common Roborock coordinates) for Q7
devices, kept up to date from two sources:

- the current pose in live map frames (`currentPose`), ignoring the
  `(1100, 1100)` and `(0, 0)` placeholders the firmware reports when the
  pose is unknown or outside the map;
- `cur_path` samples in unsolicited `prop.post` device pushes, which the
  device streams while a task is running.

To receive those pushes, `B01Q7Channel` now implements a `Q7PushChannel`
protocol that decodes `*.post` messages into `Q7DevicePush`, and
`Q7PropertiesApi.start()` subscribes to them.

Add `MapContentTrait.refresh_live()`, which requests the live map by type
(`service.upload_by_maptype`). Unlike the saved map it carries the current
pose and makes the device stream `cur_path` positions.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant